package lock;

/**
 * @Author: Yangu
 * @Created time: 2020/11/11 17:26
 * @Description :
 */
public class ThreadB extends Thread {

    private Object lock;

    public ThreadB(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            try {
                System.out.println("ThreadB start");
                lock.notify();
                System.out.println("ThreadB end");

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
//        Exception in thread "Thread-1" java.lang.IllegalMonitorStateException
//	        at java.lang.Object.notify(Native Method)
//	        at lock.ThreadB.run(ThreadB.java:28)
//        lock.notify();
    }
}
